home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / PredatorPrey / event.c < prev    next >
Text File  |  1996-06-22  |  13KB  |  432 lines

  1.         case autoKey:
  2.                 FindWindow( gTheEvent.where, &wPtr );
  3.                 if (IsOurWindow(wPtr))
  4.                 {
  5.                     DoKeystroke ();
  6.                 }
  7.                 else
  8.                 {
  9.                     theChar = gTheEvent.message & charCodeMask;
  10.                     if ((( gTheEvent.modifiers & cmdKey )/* && ( gTheEvent.modifiers & optionKey )*/) != 0)
  11.                             HandleMenuChoice( MenuKey( theChar ) );
  12.                     else if((gTheEvent.modifiers & optionKey)&&(gTheEvent.modifiers & controlKey))
  13.                     {
  14.                         if ((theChar == 23))                    /* control-option-w */
  15.                         {
  16.                             GetMouse(&pt);
  17.                             if (PtInRect(pt, &gDivideRect ))
  18.                             {
  19.                                 DoTheWiz();                        /* in calc_dipshit.c */
  20.                             }
  21.                         }
  22.                         if ((theChar == 8))                    /* control-option-h */
  23.                         {
  24.                             if(!gHelpNot) gHelpNot = TRUE;
  25.                             else gHelpNot = FALSE;
  26.                         }
  27.                         if ((theChar == 16) && (gIsWizard))        /* control-option-p */
  28.                         {
  29.                             DoTheShare();                        /* in calc_inits.c */
  30.                         }
  31.                         if ((theChar == 19) && (gIsWizard))        /* control-option-s */
  32.                         {
  33.                             DoSetPassword();
  34.                         }
  35.                         if ((theChar == 25) && (stillWizard))        /* control-option-y */
  36.                         {
  37.                             sound = GetResource ('snd ', MutateID);
  38.                             if (sound != NULL)
  39.                             {
  40.                                 errCode = SndPlay (NULL, sound, false);
  41.                             }    
  42.                             if(gIsWizard)
  43.                             {
  44.                                 gIsWizard = FALSE;
  45.                                 DelMenuItem( GetMHandle(FILE_MENU_ID), 6 );
  46.                                 InsMenuItem( GetMHandle(FILE_MENU_ID), "\pLoad Program/L", 5 );
  47.                                 DelMenuItem( GetMHandle(FILE_MENU_ID), 7 );
  48.                                 InsMenuItem( GetMHandle(FILE_MENU_ID), "\pLoad Data/L", 6 );
  49.                             }
  50.                             else
  51.                             {    
  52.                                 gIsWizard = TRUE;
  53.                                 DelMenuItem( GetMHandle(FILE_MENU_ID), 6 );
  54.                                 InsMenuItem( GetMHandle(FILE_MENU_ID), "\pOpen Program/L", 5 );
  55.                                 DelMenuItem( GetMHandle(FILE_MENU_ID), 7 );
  56.                                 InsMenuItem( GetMHandle(FILE_MENU_ID), "\pOpen Data/L", 6 );
  57.                             }
  58.                             if(!gLoadProgEnabled)
  59.                             {
  60.                                 DisableItem(GetMHandle(FILE_MENU_ID), 6);
  61.                                 DisableItem(GetMHandle(FILE_MENU_ID), 7);
  62.                             }
  63.                         }
  64.                         if((theChar == 96))
  65.                         {
  66.                             /* Do option-control-` */
  67.                         }
  68.                         
  69.                     }
  70.     
  71.                             /*    else if((gTheEvent.modifiers & optionKey)&&(gTheEvent.modifiers & cmdKey))*/
  72.                             /*    {*/
  73.                             /*    }*/
  74.     
  75.                     else
  76.                     {
  77.                         charCode = gTheEvent.message & charCodeMask;
  78.     
  79.                         switch(charCode)
  80.                         {
  81.                             case 9:                        /*    tab char    */
  82.                                 wPtr = FrontWindow();
  83.                                 if(one_of_mine(wPtr) || wPtr == gRotateBox || wPtr == gStretchBox)
  84.                                 {
  85.                                     palSet = (**w_objs_hndl).paletteSetting;
  86.                                     if(palSet == CIRCLE_OBJ)
  87.                                     {
  88.                                         weapon_type = (**w_objs_hndl).armament_type;
  89.                                         if(weapon_type == 0) draw_palette(lastPtr);    /*    in calc_update.c    */
  90.                                         else if(weapon_type == 1)
  91.                                         {
  92.                                             if((**w_objs_hndl).arms_selected == 0)    (**w_objs_hndl).arms_selected = 1;
  93.                                             else if((**w_objs_hndl).arms_selected == 1) (**w_objs_hndl).arms_selected = 0;
  94.                                             draw_palette(lastPtr);    /*    in calc_update.c    */
  95.                                         }
  96.                                         else if (weapon_type == 2)
  97.                                         {
  98.                                             if((**w_objs_hndl).arms_selected == 0)    (**w_objs_hndl).arms_selected = 1;
  99.                                             else if((**w_objs_hndl).arms_selected == 1)    (**w_objs_hndl).arms_selected = 2;
  100.                                             else if((**w_objs_hndl).arms_selected == 2) (**w_objs_hndl).arms_selected = 0;
  101.                                             draw_palette(lastPtr);    /*    in calc_update.c    */
  102.                                         }
  103.                                     }
  104.                                     else if(palSet == SQUARE_OBJ)
  105.                                     {
  106.                                         vPtChoice = (**w_objs_hndl).vPtNo;
  107.                                         switch(vPtChoice)
  108.                                         {
  109.                                             case 0:
  110.                                                 (**w_objs_hndl).xvPt = 100;
  111.                                                 (**w_objs_hndl).yvPt = 100;
  112.                                                 (**w_objs_hndl).vPtNo = 1;
  113.                                                 break;
  114.                                             case 1:
  115.                                                 (**w_objs_hndl).xvPt = 200;
  116.                                                 (**w_objs_hndl).yvPt = 100;
  117.                                                 (**w_objs_hndl).vPtNo = 2;
  118.                                                 break;
  119.                                             case 2:
  120.                                                 (**w_objs_hndl).xvPt = 300;
  121.                                                 (**w_objs_hndl).yvPt = 100;
  122.                                                 (**w_objs_hndl).vPtNo = 3;
  123.                                                 break;
  124.                                             case 3:
  125.                                                 (**w_objs_hndl).xvPt = 400;
  126.                                                 (**w_objs_hndl).yvPt = 100;
  127.                                                 (**w_objs_hndl).vPtNo = 4;
  128.                                                 break;
  129.                                             case 4:
  130.                                                 (**w_objs_hndl).xvPt = 500;
  131.                                                 (**w_objs_hndl).yvPt = 100;
  132.                                                 (**w_objs_hndl).vPtNo = 5;
  133.                                                 break;
  134.                                             case 5:
  135.                                                 (**w_objs_hndl).xvPt = 600;
  136.                                                 (**w_objs_hndl).yvPt = 100;
  137.                                                 (**w_objs_hndl).vPtNo = 6;
  138.                                                 break;
  139.                                             case 6:
  140.                                                 (**w_objs_hndl).xvPt = 100;
  141.                                                 (**w_objs_hndl).yvPt = 200;
  142.                                                 (**w_objs_hndl).vPtNo = 7;
  143.                                                 break;
  144.                                             case 7:
  145.                                                 (**w_objs_hndl).xvPt = 200;
  146.                                                 (**w_objs_hndl).yvPt = 200;
  147.                                                 (**w_objs_hndl).vPtNo = 8;
  148.                                                 break;
  149.                                             case 8:
  150.                                                 (**w_objs_hndl).xvPt = 300;
  151.                                                 (**w_objs_hndl).yvPt = 200;
  152.                                                 (**w_objs_hndl).vPtNo = 9;
  153.                                                 break;
  154.                                             case 9:
  155.                                                 (**w_objs_hndl).xvPt = 400;
  156.                                                 (**w_objs_hndl).yvPt = 200;
  157.                                                 (**w_objs_hndl).vPtNo = 10;
  158.                                                 break;
  159.                                             case 10:
  160.                                                 (**w_objs_hndl).xvPt = 500;
  161.                                                 (**w_objs_hndl).yvPt = 200;
  162.                                                 (**w_objs_hndl).vPtNo = 11;
  163.                                                 break;
  164.                                             case 11:
  165.                                                 (**w_objs_hndl).xvPt = 600;
  166.                                                 (**w_objs_hndl).yvPt = 200;
  167.                                                 (**w_objs_hndl).vPtNo = 12;
  168.                                                 break;
  169.                                             case 12:
  170.                                                 (**w_objs_hndl).xvPt = 100;
  171.                                                 (**w_objs_hndl).yvPt = 300;
  172.                                                 (**w_objs_hndl).vPtNo =13;
  173.                                                 break;
  174.                                             case 13:
  175.                                                 (**w_objs_hndl).xvPt = 200;
  176.                                                 (**w_objs_hndl).yvPt = 300;
  177.                                                 (**w_objs_hndl).vPtNo = 14;
  178.                                                 break;
  179.                                             case 14:
  180.                                                 (**w_objs_hndl).xvPt = 300;
  181.                                                 (**w_objs_hndl).yvPt = 300;
  182.                                                 (**w_objs_hndl).vPtNo = 15;
  183.                                                 break;
  184.                                             case 15:
  185.                                                 (**w_objs_hndl).xvPt = 400;
  186.                                                 (**w_objs_hndl).yvPt = 300;
  187.                                                 (**w_objs_hndl).vPtNo = 16;
  188.                                                 break;
  189.                                             case 16:
  190.                                                 (**w_objs_hndl).xvPt = 500;
  191.                                                 (**w_objs_hndl).yvPt = 300;
  192.                                                 (**w_objs_hndl).vPtNo = 17;
  193.                                                 break;
  194.                                             case 17:
  195.                                                 (**w_objs_hndl).xvPt = 600;
  196.                                                 (**w_objs_hndl).yvPt = 300;
  197.                                                 (**w_objs_hndl).vPtNo = 18;
  198.                                                 break;
  199.                                             case 18:
  200.                                                 (**w_objs_hndl).xvPt = 100;
  201.                                                 (**w_objs_hndl).yvPt = 400;
  202.                                                 (**w_objs_hndl).vPtNo = 19;
  203.                                                 break;
  204.                                             case 19:
  205.                                                 (**w_objs_hndl).xvPt = 200;
  206.                                                 (**w_objs_hndl).yvPt = 400;
  207.                                                 (**w_objs_hndl).vPtNo = 20;
  208.                                                 break;
  209.                                             case 20:
  210.                                                 (**w_objs_hndl).xvPt = 300;
  211.                                                 (**w_objs_hndl).yvPt = 400;
  212.                                                 (**w_objs_hndl).vPtNo = 21;
  213.                                                 break;
  214.                                             case 21:
  215.                                                 (**w_objs_hndl).xvPt = 400;
  216.                                                 (**w_objs_hndl).yvPt = 400;
  217.                                                 (**w_objs_hndl).vPtNo = 22;
  218.                                                 break;
  219.                                             case 22:
  220.                                                 (**w_objs_hndl).xvPt = 500;
  221.                                                 (**w_objs_hndl).yvPt = 400;
  222.                                                 (**w_objs_hndl).vPtNo = 23;
  223.                                                 break;
  224.                                             case 23:
  225.                                                 (**w_objs_hndl).xvPt = 600;
  226.                                                 (**w_objs_hndl).yvPt = 400;
  227.                                                 (**w_objs_hndl).vPtNo = 0;
  228.                                                 break;
  229.                                         }
  230.                                         InvalRect(&lastPtr->portRect);
  231.                                         do_update(lastPtr);
  232.                                     }
  233.                                     else if(palSet == T_BACKGRND_OBJ || palSet == BACKGRND_OBJ)
  234.                                     {
  235.                                         focalPtChoice = (**w_objs_hndl).focalPtNo;
  236.                                         switch(focalPtChoice)
  237.                                         {
  238.                                             case 0:
  239.                                                 (**w_objs_hndl).focalPtNo = 1;
  240.                                                 (**w_objs_hndl).focalLn = 1000;
  241.                                                 break;
  242.                                             case 1:
  243.                                                 (**w_objs_hndl).focalPtNo = 2;
  244.                                                 (**w_objs_hndl).focalLn = 500;
  245.                                                 break;
  246.                                             case 2:
  247.                                                 (**w_objs_hndl).focalPtNo = 3;
  248.                                                 (**w_objs_hndl).focalLn = 400;
  249.                                                 break;
  250.                                             case 3:
  251.                                                 (**w_objs_hndl).focalPtNo = 4;
  252.                                                 (**w_objs_hndl).focalLn = 300;
  253.                                                 break;
  254.                                             case 4:
  255.                                                 (**w_objs_hndl).focalPtNo = 5;
  256.                                                 (**w_objs_hndl).focalLn = 200;
  257.                                                 break;
  258.                                             case 5:
  259.                                                 (**w_objs_hndl).focalPtNo = 6;
  260.                                                 (**w_objs_hndl).focalLn = 100;
  261.                                                 break;
  262.                                             case 6:
  263.                                                 (**w_objs_hndl).focalPtNo = 7;
  264.                                                 (**w_objs_hndl).focalLn = 50;
  265.                                                 break;
  266.                                             case 7:
  267.                                                 (**w_objs_hndl).focalPtNo = 8;
  268.                                                 (**w_objs_hndl).focalLn = 20;
  269.                                                 break;
  270.                                             case 8:
  271.                                                 (**w_objs_hndl).focalPtNo = 9;
  272.                                                 (**w_objs_hndl).focalLn = 10;
  273.                                                 break;
  274.                                             case 9:
  275.                                                 (**w_objs_hndl).focalPtNo = 0;
  276.                                                 (**w_objs_hndl).focalLn = 10000;
  277.                                                 break;
  278.                                         }
  279.                                         InvalRect(&lastPtr->portRect);
  280.                                         do_update(lastPtr);
  281.                                     }
  282.                                 }
  283.                             }
  284.                             break;
  285.                         case 32:                    /*    space bar    */
  286.                             wPtr = FrontWindow();
  287.                             if(one_of_mine(wPtr) || wPtr == gRotateBox || wPtr == gStretchBox)
  288.                                 FireGuns(innerSel,outerSel);        /*    calc_dork.c    */
  289.                             //if((**w_objs_hndl).arms_selected == 1)
  290.                             //    GuideMissle(innerSel,outerSel);        /*    calc_dork.c    */
  291.                             break;
  292.                         case 48:
  293.                             myItemHit = ZERO_BUTTON;
  294.                             HandleButtonEvent( myItemHit );
  295.                             break;
  296.                         case 49:
  297.                             myItemHit = ONE_BUTTON;
  298.                             HandleButtonEvent( myItemHit );
  299.                             break;
  300.                         case 50:
  301.                             myItemHit = TWO_BUTTON;
  302.                             HandleButtonEvent( myItemHit );
  303.                             break;
  304.                         case 51:
  305.                             myItemHit = THREE_BUTTON;
  306.                             HandleButtonEvent( myItemHit );
  307.                             break;
  308.                         case 52:
  309.                             myItemHit = FOUR_BUTTON;
  310.                             HandleButtonEvent( myItemHit );
  311.                             break;
  312.                         case 53:
  313.                             myItemHit = FIVE_BUTTON;
  314.                             HandleButtonEvent( myItemHit );
  315.                             break;
  316.                         case 54:
  317.                             myItemHit = SIX_BUTTON;
  318.                             HandleButtonEvent( myItemHit );                        
  319.                             break;
  320.                         case 55:
  321.                             myItemHit = SEVEN_BUTTON;
  322.                             HandleButtonEvent( myItemHit );                        
  323.                             break;
  324.                         case 56:
  325.                             myItemHit = EIGHT_BUTTON;
  326.                             HandleButtonEvent( myItemHit );
  327.                             break;
  328.                         case 57:
  329.                             myItemHit = NINE_BUTTON;
  330.                             HandleButtonEvent( myItemHit );
  331.                             break;
  332.                         case 46:
  333.                             myItemHit = DECIMAL_BUTTON;
  334.                             HandleButtonEvent( myItemHit );
  335.                             break;
  336.                         case 43:
  337.                             myItemHit = PLUS_BUTTON;
  338.                             HandleButtonEvent( myItemHit );
  339.                             break;
  340.                         case 42:
  341.                             myItemHit = TIMES_BUTTON;
  342.                             HandleButtonEvent( myItemHit );
  343.                             break;
  344.                         case 45:
  345.                             myItemHit = MINUS_BUTTON;
  346.                             HandleButtonEvent( myItemHit );
  347.                             break;
  348.                         case 47:
  349.                             myItemHit = DIVIDE_BUTTON;
  350.                             HandleButtonEvent( myItemHit );
  351.                             break;
  352.                         case 03:
  353.                             myItemHit = ENTER_BUTTON;
  354.                             HandleButtonEvent( myItemHit );
  355.                             break;
  356.                         case 28:
  357.                             myItemHit = ERASE_BUTTON;
  358.                             HandleButtonEvent( myItemHit );
  359.                             break;
  360.                         case 102:
  361.                         case 70:
  362.                             myItemHit = FFXN_BUTTON;
  363.                             HandleButtonEvent( myItemHit );
  364.                             break;
  365.                         case 103:
  366.                         case 71:
  367.                             myItemHit = GFXN_BUTTON;
  368.                             HandleButtonEvent( myItemHit );
  369.                             break;
  370.                         case 105:    /*    "i"    */
  371.                         case 73:    /*    "I"    */
  372.                             myItemHit = SIN_BUTTON;
  373.                             HandleButtonEvent( myItemHit );
  374.                             break;
  375.                         case 109:    /*    "m"    */
  376.                         case 77:    /*    "M"    */
  377.                             myItemHit = CHS_BUTTON;
  378.                             HandleButtonEvent( myItemHit );
  379.                             break;
  380.                         case 30:
  381.                             myItemHit = GFXN_BUTTON;
  382.                             HandleButtonEvent( myItemHit );                        
  383.                             myItemHit = ROLLDN_BUTTON;
  384.                             HandleButtonEvent( myItemHit );
  385.                             break;
  386.                         case 31:
  387.                             myItemHit = ROLLDN_BUTTON;
  388.                             HandleButtonEvent( myItemHit );
  389.                             break;
  390.                         case 115:
  391.                         case 83:
  392.                             myItemHit = STO_BUTTON;    /*    STO_BUTTON is 36    */
  393.                             HandleButtonEvent( myItemHit );
  394.                             break;
  395.                         case 114:
  396.                         case 82:
  397.                             myItemHit = RCL_BUTTON;
  398.                             HandleButtonEvent( myItemHit );
  399.                             break;
  400.                         case 29:
  401.                             myItemHit = EXCHXY_BUTTON;
  402.                             HandleButtonEvent( myItemHit );
  403.                             break;
  404.                         case 65:                            /*    "A"    */
  405.                         case 97:                            /*    "a"    */
  406.                             myItemHit = SQRT_BUTTON;
  407.                             HandleButtonEvent( myItemHit );
  408.                             break;
  409.                         case 66:                            /*    "B"    */
  410.                         case 98:                            /*    "b"    */
  411.                             myItemHit = ETOX_BUTTON;
  412.                             HandleButtonEvent( myItemHit );
  413.                             break;
  414.                         case 67:                            /*    "C"    */
  415.                         case 99:                            /*    "c"    */
  416.                             myItemHit = TENTOX_BUTTON;
  417.                             HandleButtonEvent( myItemHit );
  418.                             break;
  419.                         case 68:                            /*    "D"    */
  420.                         case 100:                            /*    "d"    */
  421.                             myItemHit = YTOX_BUTTON;
  422.                             HandleButtonEvent( myItemHit );
  423.                             break;
  424.                         case 69:                            /*    "E"    */
  425.                         case 101:                            /*    "e"    */
  426.                             myItemHit = INVERSE_BUTTON;
  427.                             HandleButtonEvent( myItemHit );
  428.                             break;
  429.                     }
  430.                 }
  431.                 break;
  432.         case keyUp: